package com.demo.servlet.demo1210;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/demo1210/demo02.do")
public class Demo02Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.使用 request 对象的域对象特性
        req.setAttribute("demo02", "Demo02Servlet 在该请求对象中加入了该键值对");
        req.setAttribute("demo", "demo02");
        //2.将带有信息的 request 对象 转发给其他Servlet
        //这个 /是给后端解析的
        req.getRequestDispatcher("/demo1210/demo03.do").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
